package cn.yeziji.forum.dao.iupdater;

import cn.yeziji.forum.wrapper.ForumAnswerUpdate;

/**
 * 答案更新器
 *
 * @author gzkemays
 * @since 2022/11/15 2:33 PM
 */
public class AnswerUpdater {
  /**
   * 更新点赞
   *
   * @param id 答案 id
   * @param opera 取消或点赞
   */
  public static ForumAnswerUpdate updateGoodUpdater(Integer id, boolean opera) {
    String applyFunc = opera ? "goodNumber + 1" : "goodNumber - 1";
    return new ForumAnswerUpdate()
        .set
        .goodNumber()
        .applyFunc(applyFunc)
        .end()
        .where
        .id()
        .eq(id)
        .end();
  }
}
